import java.util.Scanner;


public class Main {


    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        StringBuilder res=new StringBuilder();
        int beginRight=str.lastIndexOf('[');
        int endLeft=str.length();
        while (true){
            StringBuilder temp=new StringBuilder();
            if(beginRight<0 || endLeft<0){
                break;
            }
            int firstRight=str.indexOf(']',beginRight+1);
            int lastLeft=lastIndexOfLeft(str,endLeft);

            if(firstRight<0|| lastLeft<0) break;
            int num=convert2Int(str,lastLeft);
            for (int i = beginRight+1; i < firstRight; i++) {
                res.append(str.charAt(i));
            }
            for (int i = 0; i < num; i++) {
                temp.append(res);
            }
            res=temp;
            beginRight=firstRight;
            endLeft=lastLeft;
        }
        StringBuilder temp=new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if(valid(str.charAt(i))){
                temp.append(str.charAt(i));
            }else {
                break;
            }
        }
        temp.append(res);

        System.out.println(temp);
    }
    private static int lastIndexOfLeft(String str,int end){
        for (int i =end-1; i >=0 ; i--) {
            if(str.charAt(i)=='['){
                return i;
            }
        }
        return -1;
        
    }
    private static int convert2Int(String str,int begin){
        String res="";
        for (int i = begin-1; i >0; i--) {
            char c=str.charAt(i);
            if(c>='0' && c<='9'){
                res=res+c;
            }else {
                break;
            }
        }
        return Integer.valueOf(String.valueOf(res));
        
    }
    private static boolean valid(char c){
        return c>='a' && c<='z' ||(c>='A'&& c<='Z');
    }

}
//e9[xyz]
//e3[2[abc]gh]